package com.atguigu.jxc.controller;


import com.atguigu.jxc.domain.ErrorCode;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.service.GoodsTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * ClassName: GoodTypeController
 * Package: com.atguigu.jxc.controller
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/2/21 17:04
 * @Version 1.0
 */
@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {


    @Autowired
    private GoodsTypeService goodsTypeService;


    /**
     * 加载商品类型
     * @return String
     */
    @RequestMapping("/loadGoodsType")
    public String loadGoodsType() {
        return goodsTypeService.loadGoodsType();
    }

    /**
     * 保存商品类型
     * @param goodsTypeName 商品类型名称
     * @param pId 父级类型id
     */
    @PostMapping("/save")
    public ServiceVO<Object> saveGoodsType(String goodsTypeName, Integer pId) {
        return goodsTypeService.saveGoodsType(goodsTypeName, pId);
    }

    /**
     * 删除商品类型
     * @param goodsTypeId 商品类型id
     */
    @PostMapping("/delete")
    public ServiceVO<Object> deleteGoodsType(Integer goodsTypeId) {
        return goodsTypeService.deleteGoodsTypeById(goodsTypeId);
    }


}
